#include <iostream>
#include <functional>
#include <numeric>
#include <vector>
#include <algorithm>
using namespace std;
struct accu
{
    int operator()(int x, int y)
    {
        return x+2*y;
    }
};

struct cmp
{
    bool operator()(int x, int y)
    {
        return x < y;
    }
};

void display(vector<int> &table);

int main()
{
    vector<int> table = {1, 2, 3, 1, 3, 5, 78,3,4,5,2,7,854,3,21,3};
    int init = 0;
    cout << accumulate(table.begin(), table.end(), init, accu()) << endl;
    cout << accumulate(table.begin(), table.end(), init, minus<int>()) << endl;
    cout << "count call :" << count(table.begin(), table.end(), 1)<< " times" << endl;
    cout << "find call :" << *find(table.begin(), table.end(), 1)<< " times" << endl;

    display(table);
    sort(table.begin(), table.end()-1);
    display(table);
    // sort(table.rbegin(), table.rend());
    // display(table);
    cout << "\nlower_bound" << endl;
    cout << lower_bound(table.begin(), table.end(), 3)-table.begin() << endl;
}

void display(vector<int> &table)
{
    for(auto num : table)
        cout << num << " ";
    cout << endl;
}